import 'package:mc_card/model/shequ/pic_model.dart';

///
/// Feed流 Item 对象
///
class ArticleItemModel {
  final int addrType;
  final String addr;
  final String shareUrl;
  final int articleId;
  final int articleType;
  final List<PictureModel> cover;
  final int uid;
  final String username;
  final String avatar;
  final String title;
  final String ctf;
  final String desc;
  final int isfollow;
  final int likecnt;
  final bool liked;
  final int rnt;
  final bool crafts;

  ArticleItemModel(
      {this.addrType,
      this.addr,
      this.shareUrl,
      this.articleId,
      this.articleType,
      this.cover,
      this.uid,
      this.username,
      this.avatar,
      this.title,
      this.ctf,
      this.desc,
      this.isfollow,
      this.likecnt,
      this.liked,
      this.rnt,
      this.crafts});

  factory ArticleItemModel.fromJson(Map<String, dynamic> json) {

    var localCoverListJson = json['cover'] as List;
    List<PictureModel> coverList = localCoverListJson.map((i) => PictureModel.fromJson(i)).toList();

    return ArticleItemModel(
      addrType: json['addrType'],
      addr: json['addr'],
      shareUrl: json['shareUrl'],
      articleId: json['articleId'],
      articleType: json['articleType'],
      cover: coverList,
      uid: json['addrType'],
      likecnt: json['likecnt'],
      username: json['username'],
      avatar: json['avatar'],
      title: json['title'],
      ctf: json['ctf'],
      desc: json['desc'],
      isfollow: json['isfollow'],
      liked: json['liked'],
      rnt: json['rnt'],
      crafts: json['crafts'],
    );
  }
}
